<template>
  <el-container style="height: 100vh">
    <el-aside :width="asideWidth" class="aside">
      <div class="avatar_box">
        <img :src="logoSrc" alt="logo" class="avatar" />
        <span v-show="!isCollapse" class="system_name">海报设计系统</span>
      </div>
      <el-menu
        default-active="1"
        class="el-menu-vertical-demo"
        @open="handleOpen"
        @close="handleClose"
        :collapse="isCollapse"
      >
        <el-tooltip v-if="isCollapse" content="首页" placement="right" effect="dark">
          <el-menu-item index="1">
            <i class="el-icon-menu"></i>
            <span slot="title">首页</span>
          </el-menu-item>
        </el-tooltip>
        <el-submenu index="2">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span>系统管理</span>
          </template>
          <el-tooltip v-if="isCollapse" content="用户管理" placement="right" effect="dark">
            <el-menu-item index="2-1">用户管理</el-menu-item>
          </el-tooltip>
          <el-tooltip v-if="isCollapse" content="菜单管理" placement="right" effect="dark">
            <el-menu-item index="2-2">菜单管理</el-menu-item>
          </el-tooltip>
          <el-tooltip v-if="isCollapse" content="角色管理" placement="right" effect="dark">
            <el-menu-item index="2-3">角色管理</el-menu-item>
          </el-tooltip>
        </el-submenu>
        <el-tooltip v-if="isCollapse" content="海报管理" placement="right" effect="dark">
          <el-menu-item index="3">
            <i class="el-icon-document"></i>
            <span slot="title">海报管理</span>
          </el-menu-item>
        </el-tooltip>
        <el-tooltip v-if="isCollapse" content="素材管理" placement="right" effect="dark">
          <el-menu-item index="4">
            <i class="el-icon-setting"></i>
            <span slot="title">素材管理</span>
          </el-menu-item>
        </el-tooltip>
      </el-menu>
    </el-aside>
    <el-container>
      <el-header class="header">
        <div class="header-left">
          <i :class="isCollapse ? 'el-icon-s-unfold' : 'el-icon-s-fold'" @click="toggleAside"></i>
        </div>
        <div class="header-right">
          <el-avatar :src="avatarSrc" size="medium"></el-avatar>
          <el-dropdown>
            <span class="el-dropdown-link">
              admin<i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>个人中心</el-dropdown-item>
              <el-dropdown-item>退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </el-header>
      <el-main class="main">Main</el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  data() {
    return {
      logoSrc: require("../assets/logo.jpg"), // 引用 logo 图像
      avatarSrc: require("../assets/tx.jpg"), // 引用头像图像
      breadcrumbItems: [{ label: "首页", to: "/" }], // 初始化面包屑路径
      isCollapse: false,
    };
  },
  computed: {
    asideWidth() {
      return this.isCollapse ? "64px" : "200px";
    },
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    toggleAside() {
      this.isCollapse = !this.isCollapse;
    },
  },
};
</script>

<style scoped>
html,
body,
#app {
  height: 100%;
  margin: 0;
}

.el-container {
  height: 100%;
}

.el-aside {
  background-color: #333;
  color: #fff;
  height: 100%;
}

.avatar_box {
  display: flex;
  align-items: center;
  padding-left: 12px;
  background-color: #333; /* 设置为深色 */
  height: 60px;
  border-bottom: 1px solid #555;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: 10px;
}

.system_name {
  font-size: 16px;
  font-weight: bold;
  color: #fff;
  transition: opacity 0.3s; /* 添加过渡效果 */
}

.el-header {
  background-color: #b3c0d1;
  color: #333;
  line-height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
}

.header-left {
  display: flex;
  align-items: center;
}

.header-right {
  display: flex;
  align-items: center;
}

.header-right .el-avatar {
  margin-right: 10px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  flex-grow: 1;
}

.breadcrumb {
  margin-left: 20px;
  color: #333;
  font-size: 14px;
}

::v-deep .el-icon-arrow-right:before {
  color: black;
}

.breadcrumb .el-breadcrumb__inner {
  font-size: 14px;
}

.el-menu-vertical-demo {
  background-color: #333; /* 设置为深色 */
  border-right: none;
}

.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}

::v-deep .el-menu-item,
::v-deep .el-submenu__title {
  background-color: #333; /* 设置为深色 */
  color: #fff;
}

::v-deep .el-menu-item:hover,
::v-deep .el-submenu__title:hover,
::v-deep .el-menu-item.is-active {
  background-color: #444 !important;
}

::v-deep .el-tooltip__popper {
  background-color: #333; /* 设置工具提示背景色为深色 */
  color: #fff; /* 设置工具提示文字颜色为白色 */
}

::v-deep .el-tooltip__popper.is-dark .el-tooltip__arrow::before {
  border-color: #333; /* 设置工具提示箭头颜色为深色 */
}

::v-deep .el-submenu__icon-arrow {
  display: none;
}
</style>
